<!DOCTYPE html>
<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>





<body>
系统载入中，请稍等...



<?php
//验证登陆信息
session_start();

$account              = $_POST['account'];
$password             = $_POST['password'];

include_once("../config.php");


//只在登录的时候需要再引入一次。登录之后就会产生session，会在config中引入
include_once (ROOT_PATH_."/connection.php");


$_user=select_one_line_all_items($table_prefix."unit","mid = '".$account."'");

        $_url="/user/";

    //先判断接收的用户名，是否含有特殊字符。有的话，直接返回登陆框。
    if (!preg_match("/^[0-9a-zA-Z]{3,12}$/", $account))
         {
             echo "<script language='javascript'>alert('用户名不存在！')</script>";
             echo "<script language='javascript'>window.location.href='".$_url."'</script>";
         }

    elseif (!$_user)
        {
            echo "<script language='javascript'>alert('用户名不存在!');</script>";
            echo "<script language='javascript'>window.location.href='".$_url."'</script>";

        }

    elseif ($_user['status'] == '黑名单')
        {
            echo "<script language='javascript'>alert('没有登录权限！');</script>";
            echo "<script language='javascript'>window.location.href='".$_url."'</script>";

        }

    elseif ($_user['mima'] != md5($password))
        {
            echo "<br/>密码错误";
            echo "<script language='javascript'>alert('密码错误！')</script>";
            echo "<script language='javascript'>window.location.href='".$_url."'</script>";

        }


elseif($_user)
{
    if(!$_user['name']){$_user['name']=$_user['mid'];}

    echo "校验通过";
    //全部校验通过 数据存入session
    $_SESSION['username']     = $_user['name'];
    $_SESSION['department']   = $_user['department'];
    $_SESSION['departmentid'] = $_user['departmentid'];
    $_SESSION['mid']          = $_user['mid'];
    $_SESSION['nid']          = $_user['nid'];
    $_SESSION['quanxian']     = $_user['quanxian'];
    $_SESSION['position']     = $_user['position'];
    $_SESSION['utoken']       = $_user['utoken'];
    $_SESSION['unit']       = $_user['nid'];

    echo "<script language='javascript'> location='../controller/extender/dashboard/view/dashboard_unit.php';</script>";

}

?>
